package com.sq.es.util;

import com.sq.es.ana.EsSearch;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;

/**
 * @Author Li sir
 * @Date 2024/11/15
 */
public class EsSearchUtil {


    public static final String[] getEsSearchFiled(Class<?> aclass){


        ArrayList<String> fileds = new ArrayList<>();
        if (Objects.isNull(aclass)){
            throw new RuntimeException("class is null");
        }
        Field[] declaredFields = aclass.getDeclaredFields();

        for (Field field : declaredFields){
            EsSearch annotation = field.getAnnotation(EsSearch.class);
            if (Objects.isNull(annotation)){
                continue;
            }
            fileds.add(field.getName());
        }


        String[] array = fileds.toArray(new String[0]);
        return array;
    }



}
